package xyz.xpman.prisonerfitness.kit;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;

import org.jetbrains.annotations.NotNull;

import xyz.xpman.prisonerfitness.util.ToastUtil;

enum QQKit {;

    public static void toJoinGroupPage(@NotNull Context context,
                                       @NotNull String key,
                                       String passwd) {
        final String temp = "http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26jump_from%3Dwebapi%26k%3D" + key;
        final String url = "mqqopensdkapi://bizAgent/qm/qr?url=" + temp;

        try {
            if (null != passwd) {
                ToastUtil.showText(context, "加群密码：" + passwd);
            }

            context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
        } catch (Exception e) {
            e.printStackTrace();
            ToastUtil.showText(context, "未安装QQ或安装的版本不支持");
        }
    }


    public static void toAddFriendsPage(@NotNull Context context,
                                        @NotNull String qqNumber) {
        toChatPage(context, qqNumber);
    }

    /**
     * 如果没有添加好友，会跳转到添加好友页面
     * @param context context
     * @param qqNumber qq号
     */
    public static void toChatPage(@NotNull Context context,
                                  @NotNull String qqNumber) {
        final String url = "mqqwpa://im/chat?chat_type=wpa&uin=" + qqNumber;

        try {
            context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
        } catch (Exception e) {
            e.printStackTrace();
            ToastUtil.showText(context, "未安装QQ或安装的版本不支持");
        }
    }

}
